#ifndef LOGGER_H
#define LOGGER_H

#include <QFile>
#include <QTextStream>
#include <QDateTime>
#include <QMutex>
#include <QMutexLocker>
#include <QApplication>

class Logger {
public:
    static void init(const QString& fileName);
    static void log(const QString& level, const QString& message, const char* file, int line);

private:
    static QFile logFile;
    static QMutex mutex;
};

// 宏定义用于简化日志记录
#define DLOG(message) Logger::log("DEBUG", message, __FILE__, __LINE__)
#define ILOG(message) Logger::log("INFO", message, __FILE__, __LINE__)
#define WLOG(message) Logger::log("WARNING", message, __FILE__, __LINE__)
#define ELOG(message) Logger::log("ERROR", message, __FILE__, __LINE__)
#define FLOG(message) Logger::log("FATAL", message, __FILE__, __LINE__)


#endif // LOGGER_H
